<template>
  <div class="base-container">
    <!--    <t-row>-->
    <div style="position: fixed;width: 20%;height: 100%;overflow: scroll;padding-bottom: 100px">
      <t-loading size="small" :loading="dataLoading" showOverlay>
        <div>
          <t-tree line ref="tree" :expanded.sync="expanded" :keys="{value: 'id',label:'name'}" :expand-all="expandAll" expandParent :actived="actived"
                  :data="TreeReviewTeamData" @active="onTreeActive" activable hover
                  transition>
            <template #label="{ node }">
              {{ node.data.name }}<span v-if="!['1'].includes(node.data.reviewMenuType)   && node.data.projectCount" >(<span style="color: #176eff">{{ node.data.projectCount }}</span>)</span>
            </template>
            <template #operations="{ node }">
              <t-button v-if="['1'].includes(node.data.reviewMenuType)" theme="primary" size="small" variant="text" @click="dialog.header = '添加组';
              dialog.objId = 0;
              dialog.parentId = node.data.id;
              dialog.open_add_edit = true;">
                <t-icon name="add" slot="icon"/>
              </t-button>
              <t-button v-if="node.data.name!=='评审分组体系'" size="small" theme="primary" variant="text" @click="dialog.header = '编辑组';
              dialog.objId = node.data.id;
              dialog.parentId = 0;
              dialog.open_add_edit = true;">
                <t-icon name="edit-1" slot="icon"/>
              </t-button>
              <t-popconfirm v-if="node.data.name!=='评审分组体系'" @confirm="removeNode(node)" theme="warning"
                            content="确认删除分组吗">
                <t-button size="small" theme="danger"  variant="text">
                  <t-icon name="delete" slot="icon"/>
                </t-button>
              </t-popconfirm>
            </template>
          </t-tree>
        </div>
      </t-loading>
    </div>

    <!-- 右侧内容 -->
    <div style="margin-left: 24%;height: 100%;">
      <t-loading size="small" :loading="baseLoading" showOverlay>
        <t-card>
          <div>
            <template>
              <div :style="{ width: '200px' }">
                <t-divider>基本信息</t-divider>
              </div>
            </template>
            <t-form labelWidth="150px" :data="formData" ref="form" :colon="true">
              <t-row style="row-gap: 10px">
                <t-col :span="6">
                  <t-form-item label="分组名" name="name">
                    {{ formData.name }}
                  </t-form-item>
                </t-col>
                <t-col :span="6">
                  <t-form-item label="评审业务类型" name="reviewType">
                    {{ formData.reviewType | filterByDict(dict.type.cgzh_review_type) }}
                  </t-form-item>
                </t-col>
                <t-col :span="6">
                  <t-form-item label="专家评审开始时间" name="startReviewDate">
                    {{ formData.startReviewDate }}
                  </t-form-item>
                </t-col>
                <t-col :span="6">
                  <t-form-item label="专家评审截止时间" name="endReviewDate">
                    {{ formData.endReviewDate }}
                  </t-form-item>
                </t-col>
                <t-col :span="6">
                  <t-form-item label="评审会议时间" name="reviewMeetingDate">
                    {{ formData.reviewMeetingDate }}
                  </t-form-item>
                </t-col>
                <t-col :span="6">
                  <t-form-item label="分组说明" name="note">
                    {{ formData.note }}
                    <!--                      <t-textarea style="width: 240px" disabled v-model="formData.note"></t-textarea>-->
                  </t-form-item>
                </t-col>
              </t-row>
            </t-form>
            <t-divider></t-divider>
            <!-- 专家 -->
            <t-row>
              <t-col :xs="2" :sm="4" :md="6" :lg="8" :xl="9">
                <div class="btn-group-inline">
                  <t-button :disabled="!formData.id"
                            @click="handleExport(`/cgzh/excel/reviewTeamInfo`,formData.id,`${formData.name}-评审组信息`)">
                    导出评审信息
                  </t-button>
                  <t-button :disabled="!formData.id"
                            @click="handleExport(`/cgzh/excel/exportPayInfo`,formData.id, `${formData.name}-评审组付款信息`)">
                    导出账户信息
                  </t-button>
                  <!--                    <t-button :disabled="!formData.id" @click="handleGroupSms(formData.id)">专家短信邀请</t-button>-->
                </div>
              </t-col>
              <t-col :xs="10" :sm="8" :md="6" :lg="4" :xl="3">
                <div style="justify-content: flex-end" class="btn-group-inline">
                  <t-button :disabled="!formData.id" @click="selectProject">选择项目</t-button>
                  <t-tooltip v-if="projectList.length<=0" content="请先选择项目">
                    <t-button :disabled="!formData.id">
                      抽取专家
                    </t-button>
                  </t-tooltip>
                  <t-button :disabled="!formData.id" v-else @click="selectExpert">抽取专家</t-button>
                </div>
              </t-col>
            </t-row>
            <div :style="{ width: '200px' }">
              <t-divider>本组评审项目</t-divider>
            </div>
            <t-row>
              <t-table
                rowKey="id"
                :data="projectList"
                :columns="projectColumns"
                :bordered="true"
                :hover="true"
              >
                <template #[`collectResult.name`]="{ row }">
                  <t-link @click="dialog.objId=row.collectResult.id;dialog.header=row.collectResult.name;dialog.open_review=true" hover="color" theme="primary">{{row.collectResult.name}}</t-link>
                </template>
                <template #op="{row}">
                  <t-tooltip v-if="expertList.length<=0" content="请先抽取专家">
                    <t-button size="small" variant="text"
                              class="t-button-link">
                      <t-icon name="root-list" slot="icon"/>
                      专家评审详情
                    </t-button>
                  </t-tooltip>
                  <t-button v-else
                            @click="openReviewDetail(row)"
                            size="small" variant="text"
                            class="t-button-link">
                    <t-icon name="root-list" slot="icon"/>
                    专家评审详情
                  </t-button>
                  <!--                  <t-button v-if="formData.reviewType !== '1'" @click="getTeamExpertLeaderFile(row)" size="small"-->
                  <!--                            variant="text" class="t-button-link">-->
                  <!--                    <t-icon name="info-circle" slot="icon"/>-->
                  <!--                    专家组长评审意见表-->
                  <!--                  </t-button>-->
                  <t-button
                    @click="dialog.objId=row.id;dialog.projectName=row.collectResult.name;dialog.projectId=row.collectResult.id;dialog.open_project_approval=true;"
                    size="small" variant="text"
                    class="t-button-link">
                    <t-icon name="check-circle" slot="icon"/>
                    评审判定
                  </t-button>
                                      <t-button @click="dialog.header=row.collectResult.name;dialog.objId=row.collectResult.id;dialog.editOpen=false;dialog.open_project_detail=true" size="small" variant="text" class="t-button-link">
                                        <t-icon name="info-circle" slot="icon"/>
                                        详情
                                      </t-button>

                  <t-button theme="danger" @click="teamProjectDel(row.id)" size="small" variant="text"
                            class="t-button-link">
                    <t-icon name="delete" slot="icon"/>
                    删除
                  </t-button>
                </template>
                <template #projectStatus="{row}">
                  <t-tag theme="success" variant="light" v-if="row.projectStatus==='1'">
                    是
                  </t-tag>
                  <t-tag theme="danger" variant="light" v-else-if="row.projectStatus==='0'">
                    否
                  </t-tag>
                  <t-tag theme="warning" variant="light" v-else-if="row.projectStatus==='2'">
                    需要复议
                  </t-tag>
                  <t-tag theme="warning" variant="light" v-else>
                    未提交
                  </t-tag>
                </template>
              </t-table>
            </t-row>

            <!-- 本组评审专家 -->
            <t-divider></t-divider>
            <t-row>
              <t-col :xs="2" :sm="4" :md="6" :lg="8" :xl="9">
                <div class="btn-group-inline">
                  <!--                  <t-tooltip trigger="click" placement="top" theme="light">-->
                  <!--                    <div slot="content">-->
                  <!--                      <div v-for="(item,index) in temList" :key="index">-->
                  <!--                        <t-button @click="handleGroupSms(formData.id,item.id)" variant="text" class="t-button-link">-->
                  <!--                          <t-icon name="cloud" slot="icon"/>-->
                  <!--                          {{ item.type | filterByDict(dict.type.msg_template_type) }}-->
                  <!--                        </t-button>-->
                  <!--                      </div>-->
                  <!--                    </div>-->
                  <!--                    <t-button :disabled="!formData.id">-->
                  <!--                      本组专家短信邀请-->
                  <!--                    </t-button>-->
                  <!--                  </t-tooltip>-->
<!--                  <t-button :disabled="!formData.id"-->
<!--                            @click="dialog.formData=formData;dialog.sendType=1;dialog.open_sms_template=true">本组专家短信邀请-->
<!--                  </t-button>-->
                </div>
              </t-col>
            </t-row>
            <t-row>
              <template>
                <div :style="{ width: '200px' }">
                  <t-divider>本组评审专家</t-divider>
                </div>
              </template>
              <t-row>
                <t-table
                  rowKey="id"
                  :data="expertList"
                  :columns="expertColumns"
                  :bordered="true"
                  :hover="true"
                >
                  <template #[`experts.sysUser.nickName`]="{ row }">
                    <t-badge v-if="row.teamLeader==='1' && !['1'].includes(formData.reviewType)" count="组长"
                             :offset="[-10, -6]">
                      <t-link style="margin-right: 0" @click="dialog.objId=row.experts.id;dialog.idCard=row.experts.sysUser.idCard;dialog.header=row.experts.sysUser.nickName;dialog.open_expert_detail=true" hover="color" theme="primary">
                        {{row.experts.sysUser.nickName}}<span v-if="row.experts.isInviteExpert==='1'" style="color: red">(邀)</span>
                      </t-link>
                    </t-badge>
                    <template v-else>
                      <t-link  @click="dialog.objId=row.experts.id;dialog.idCard=row.experts.sysUser.idCard;dialog.header=row.experts.sysUser.nickName;dialog.open_expert_detail=true" hover="color" theme="primary">
                        {{row.experts.sysUser.nickName}}<span v-if="row.experts.isInviteExpert==='1'" style="color: red">(邀)</span>
                      </t-link>
                    </template>
                  </template>
                  <template #[`experts.sysUser.duty`]="{ row }">
                    <div v-if="['99999',''].includes(row.experts.sysUser?.profTit)">
                      {{ row.experts.sysUser?.duty }}
                    </div>
                    <div v-else>
                      <t-tooltip :content="getDuty(row.experts.sysUser?.duty, row.experts.sysUser?.profTit)">
                        <p class="duty-text">
                          {{ row.experts.sysUser?.duty }}/{{
                            row.experts.sysUser?.profTit | filterByDict(dict.type.prof_tit)
                          }}
                        </p>
                      </t-tooltip>
                    </div>
                  </template>
                  <template #[`experts.sysUser.education`]="{ row }">
                    {{
                      row.experts.sysUser?.education | filterByDict(dict.type.education)
                    }}/{{ row.experts.sysUser?.degree | filterByDict(dict.type.degree) }}
                  </template>
                  <!--                    <template #[`experts.sysUser.degree`]="{ row }">-->
                  <!--                      {{ row.experts.sysUser?.degree | filterByDict(dict.type.degree) }}-->
                  <!--                    </template>-->
                  <template #[`sendMsg`]="{ row }">
                    <t-tag v-if="row.sendMsg==='1'" theme="success" variant="light">发送成功</t-tag>
                    <t-tag v-else-if="row.sendMsg==='0'" theme="danger" variant="light">发送失败</t-tag>
                    <t-tag v-else theme="warning" variant="light">未发送</t-tag>
                    /
                    <t-tag v-if="row.joinType==='1'" theme="success" variant="light">参加</t-tag>
                    <t-tag v-else-if="row.joinType==='0'" theme="danger" variant="light">不参加</t-tag>
                    <t-tag v-else theme="warning" variant="light">未回复</t-tag>
                  </template>
                  <template #op="{row}">
                    <t-button
                      @click="dialog.formData=formData;dialog.objId=row.id;dialog.sendType=2;dialog.nickName=row.experts.sysUser.nickName;dialog.open_sms_template=true"
                      size="small" variant="text"
                      class="t-button-link">
                      <t-icon name="cloud" slot="icon"/>
                      短信邀请
                    </t-button>
                    <t-button v-if="formData.reviewType!=='1'" @click="setTeamExpertLeader(row)" size="small"
                              variant="text"
                              class="t-button-link">
                      <t-icon name="edit-1" slot="icon"/>
                      设为组长
                    </t-button>
                    <t-button theme="danger" @click="teamExpertDel(row.id)" size="small" variant="text"
                              class="t-button-link">
                      <t-icon name="delete" slot="icon"/>
                      删除
                    </t-button>
                  </template>
                </t-table>
              </t-row>
            </t-row>
          </div>
        </t-card>
      </t-loading>
    </div>

    <!--    </t-row>-->
    <!-- 添加分组  编辑分组 -->
    <add-edit-group @reload="getListReviewTeam()" @changeActived="changeActived" :header="dialog.header"
                    :parentId="dialog.parentId"
                    :objId="dialog.objId" :visible.sync="dialog.open_add_edit" v-if="dialog.open_add_edit">
    </add-edit-group>
    <select-project header="选择项目"
                    @reload="teamProjectGet"
                    :formData="formData" :visible.sync="dialog.open_select_project"
                    v-if="dialog.open_select_project">
    </select-project>
    <select-expert header="抽取专家"
                   @reload="teamExpertGet"
                   :formData="formData"
                   :visible.sync="dialog.open_select_expert" v-if="dialog.open_select_expert"></select-expert>
    <expert-review-list :rowId="dialog.rowId" :expert-leader="dialog.expertLeader" :teamId="dialog.teamId" :objId="dialog.objId" :reviewType="formData.reviewType"
                        :projectName="dialog.name" :visible.sync="dialog.open_review_list"
                        v-if="dialog.open_review_list"></expert-review-list>


    <project-approval @reload="teamProjectGet" :header="dialog.header" :projectName="dialog.projectName"
                      :reviewType="formData.reviewType" :projectId="dialog.projectId" :objId="dialog.objId"
                      :visible.sync="dialog.open_project_approval"
                      v-if="dialog.open_project_approval"></project-approval>


    <expert-sms-template @reload="teamExpertGet" :nick-name="dialog.nickName" :form-data="dialog.formData"
                         :send-type="dialog.sendType" :obj-id="dialog.objId" :visible.sync="dialog.open_sms_template"
                         v-if="dialog.open_sms_template"></expert-sms-template>
    <expert-detail-dialog :header="dialog.header" :obj-id="dialog.objId" :id-card="dialog.idCard" :visible.sync="dialog.open_expert_detail"
                          v-if="dialog.open_expert_detail"></expert-detail-dialog>
    <file-review :header="dialog.header" achievementType="zjb" :visible.sync="dialog.open_review" v-if="dialog.open_review" :objId="dialog.objId"></file-review>
    <collect-detail-dialog :objId="dialog.objId" :header="dialog.header" :visible.sync="dialog.open_project_detail" v-if="dialog.open_project_detail">
    </collect-detail-dialog>
  </div>
</template>

<script>
import addEditGroup from "./components/add-edit-group.vue";
import SelectProject from "./components/select-project.vue";
import SelectExpert from "./components/select-expert.vue";
import ProjectApproval from "./components/project-approval.vue";

import ExpertReviewList from "./components/expert-review-list.vue";
import ExpertSmsTemplate from "./components/expert-sms-template.vue";
import {getFilesByUserId} from "@/api/common";
import ExpertDetailDialog from "../../zjk/expert/components/expert-detail-dialog.vue";
import fileReview from "../components/file-review.vue";
import collectDetailDialog from "../collect/components/collect-detail-dialog.vue";
import filters from "@/filters/index"

export default {
  name: "review-group",
  components: {
    addEditGroup,
    SelectExpert,
    SelectProject,
    ExpertReviewList,
    ProjectApproval,
    ExpertSmsTemplate,
    ExpertDetailDialog,
    fileReview,
    collectDetailDialog
  },
  dicts: ["prof_tit", "duty", "cgzh_review_type", "education", "degree", "msg_template_type", "kjxm_ys_review_status"],
  data() {
    return {
      tabDefaultValue: "1",
      actived: [],
      dataOptions: [],
      projectList: [],
      expertList: [],
      projectColumns: [
        {
          colKey: "collectResult.name",
          title: "成果名称",
          align: "center",
          width: 180
        },
        {
          colKey: "collectResult.technosphere",
          title: "技术领域",
          align: "center"
        },
        {
          colKey: "collectResult.resultType",
          title: "成果类型",
          align: "center"
        },
        {
          colKey: "collectResult.resultForm",
          title: "成果形式",
          align: "center",
          width: 180
        },
        {
          colKey: "collectResult.company",
          title: "完成单位",
          align: "center",
          width: 180
        },
        {
          colKey: "collectResult.linkMan",
          title: "联系人",
          align: "center"
        },
        {
          colKey: "collectResult.linkPhone",
          title: "联系电话",
          align: "center"
        },
        {colKey: 'projectStatus', title: '是否通过', align: "center", width: 120},
        {
          colKey: 'op',
          title: '操作',
          align: "center",
          width: 140,
          fixed: 'right'
        },
      ],
      expertColumns: [
        {colKey: 'experts.sysUser.nickName', title: '专家姓名', align: "center"},
        {colKey: 'experts.age', title: '年龄', align: 'center', width: 80},
        {colKey: 'experts.sysUser.dept.deptName', title: '所在单位', align: "center", width: 180},
        {colKey: 'experts.sysUser.phonenumber', title: '手机号', align: "center", width: 130},
        {colKey: 'experts.sysUser.duty', title: '职务/职称', align: "center"},
        // { colKey: 'experts.declareDeptName', title: '部门', },
        {colKey: 'experts.recommendMajorName', title: '组别', align: "center", width: 120},
        // {colKey: 'experts.sysUser.majorName', title: '专业',align: "center"},
        {colKey: 'experts.sysUser.majorNowName', title: '现从事专业', align: "center"},
        {colKey: 'experts.sysUser.education', title: '学历/学位', align: "center"},
        // {colKey: 'experts.sysUser.degree', title: '学位',align: "center"},
        {colKey: 'sendMsg', title: '短信通知/是否参加', align: "center", width: 160},
        // {colKey: 'experts.joinType', title: '是否参加',align: "center"},
        // {colKey: 'experts.joinReviewTimes', title: '参与评审次数',align: "center"},
        // {colKey: 'experts.joinProjectTimes', title: '参与项目次数',align: "center"},

        // {colKey: 'experts.phoneNumber', title: '联系方式',align: "center"},
        {
          colKey: 'op',
          title: '操作',
          align: "center",
          width: 140,
          fixed: 'right'
        },
      ],
      visible: false,
      useActived: true,
      activeId: '',
      activeIds: [],
      expandAll: true,
      expanded: [],
      TreeReviewTeamData: [],
      selectTreeTeamObj: {},
      dialog: {
        parentId: 0,
        objId: 0,
        teamId: 0,
        projectId: 0,
        editOpen: false,
        open_add_edit: false,
        header: "",
        open_review_list: false,
        open_select_project: false,
        open_select_expert: false,
        open_project_approval: false,
        projectName: '',
        open_project_detail: false,
        open_review_standard: false,
        open_outline_detail: false,
        open_acceptance_detail: false,
        open_sms_template: false,
        open_expert_detail: false,
        formData: {},
        nickName: '',
        projectList: [],
        expertLeader: {},
        rowId: null,
        open_item_detail: false,
        idCard: '',
        open_review: false,
      },
      requiredRules: {
        name: [
          {required: true, message: "分组名不能为空"}
        ],
      },
      formData: {
        id: '',
        reviewType: '',
        name: '',// 分组名
        note: '',
        subjectClassification: [],
        planName: "",
        reviewMeetingDate: ''
      },
      baseLoading: false,
      dataLoading: false,
      temList: [],
      site_tag: import.meta.env.VITE_SITE_TAG,
    }
  },
  watch: {
    'formData.id': {
      immediate: true,
      handler(val) {
        if (this.formData.id) {
          this.teamProjectGet();
          this.teamExpertGet();
        }
      }
    },
  },
  created() {
    this.dataLoading = true
    this.getListReviewTeam()
  },
  methods: {
    openReviewDetail(row) {
      this.dialog.objId = row.collectResult.id;
      this.dialog.teamId = this.formData.id;
      this.dialog.name = row.collectResult.name;
      // 先判断有没有设置专家组长
      let expertLeader = null;
      const obj = this.expertList.find((val) => val.teamLeader === '1')
      if (obj) {
        expertLeader = {
          id: obj.experts.userId,
          nickName: obj.experts.sysUser.nickName
        }
      }
      this.dialog.expertLeader = expertLeader;
      this.dialog.rowId = row.id;
      this.dialog.open_review_list = true;

    },
    getTeamExpertLeaderFile(row) {
      // 先判断有没有设置专家组长
      const obj = this.expertList.find((val) => val.teamLeader === '1')
      if (!obj) {
        this.$message.error('未设置专家组组长!');
        return false;
      }
      // 获取当前组长的评审意见表附件
      getFilesByUserId(row.id, obj.experts.sysUser.id).then((res) => {
        const files = {}
        res.data.forEach((item) => {
          if (!files[item.moduleKey]) {
            files[item.moduleKey] = []
          }
          files[item.moduleKey].push({
            name: item.fileName,
            url: item.fullFilePath,
            id: item.id,
            filePath: item.filePath
          })
        })
        const dgPsYjsFilesNow = files.dgPsYjs || [];
        if (dgPsYjsFilesNow.length > 0) {
          window.open(dgPsYjsFilesNow[0].url, '_blank')
        } else {
          this.$message.error(`${obj.experts.sysUser.nickName}-还未提交评审意见表`);
        }
      }).catch(e => {
        this.$message.error(e.toString())
      })
    },
    handleExport(url,id, title) {
      this.$download(url, {teamId:id}, `${title}_${new Date().getTime()}.xls`)
    },
    getDuty(duty, profTit) {
      const newProfTit = filters.filterByDict(profTit, this.dict.type.prof_tit, null)
      return `${duty}/${newProfTit}`;
    },
    changeActived(id) {
      this.actived = [id]
      this.$api.cgzh.review.teamGet(id).then((response) => {
        response.data.subjectClassification = response.data.subjectClassification ? response.data.subjectClassification.split(",").filter(item=> item !== '') : []
        Object.assign(this.formData, response.data);
      }).catch((e) => {
        this.$message.error(e.toString());
      });
    },
    removeNode(node) {
      this.$api.cgzh.review.teamDel(node.data.id).then(
        (res) => {
          this.getListReviewTeam();
          this.$message.success("删除成功");
        }
      ).catch((e) => {
        this.$message.error(e.toString());
      });
    },
    // 获取树形
    getTreeReviewTeam() {
      this.$api.cgzh.review.teamTree().then((res) => {
        this.dataLoading = false
        // this.TreeReviewTeamData = res.data;
      }).catch((e) => {
        this.dataLoading = false
        this.$message.error(e.toString());
      });
    },
    getListReviewTeam() {
      this.$api.cgzh.review.teamList().then((res) => {
        this.dataLoading = false
        this.TreeReviewTeamData = this.handleTree(res.data, "id");
      }).catch((e) => {
        this.dataLoading = false
        this.$message.error(e.toString());
      });
    },
    onTreeActive(value, context) {
      this.actived = [context.node.data.id]
      if (context.node.data.reviewMenuType === '2') {
        this.$api.cgzh.review.teamGet(context.node.data.id).then((response) => {
          response.data.subjectClassification = response.data.subjectClassification ? response.data.subjectClassification.split(",").filter(item=> item !== '') : []
          Object.assign(this.formData, response.data);
        }).catch((e) => {
          this.$message.error(e.toString());
        });
      } else {
        this.formData.id = null;
      }
    },
    // 本组申报项目列表
    teamProjectGet() {
      this.$api.cgzh.review.teamProjectGet(this.formData.id).then((response) => {
        this.projectList = response.data;
      }).catch((e) => {
        this.$message.error(e.toString());
      });
    },
    // 查专家列表
    teamExpertGet() {
      this.$api.cgzh.review.teamExpertGet(this.formData.id).then((response) => {
        this.expertList = response.data;
      }).catch((e) => {
        this.$message.error(e.toString());
      });
    },
    selectProject() {
      if (!this.formData.id) {
        return this.$message.error('请选择分组')
      }
      this.dialog.projectList = this.projectList;
      this.dialog.open_select_project = true;
    },
    selectExpert() {
      if (!this.formData.id) {
        return this.$message.error('请选择分组')
      }
      this.dialog.open_select_expert = true
    },
    // 删除项目
    teamProjectDel(id) {
      const confirmDia = this.$dialog.confirm({
        header: "系统提示",
        body: `是否确认删除？`,
        theme: "warning",
        onConfirm: ({e}) => {
          confirmDia.update({
            confirmBtn: {
              loading: true,
            },
          })
          this.$api.cgzh.review.teamProjectDel(id).then(res => {
            this.$message.success('删除成功')
            this.teamProjectGet();
            confirmDia.destroy();
          }).catch((e) => {
            confirmDia.update({
              confirmBtn: {
                loading: false,
              },
            })
            this.$message.error(e.toString());
          });
        },
      })
    },

    setTeamExpertLeader(row) {
      const confirmDia = this.$dialog.confirm({
        header: "系统提示",
        body: `是否设置"${row.experts.sysUser.nickName}"为本组专家评审组长?`,
        theme: "warning",
        onConfirm: ({e}) => {
          confirmDia.update({
            confirmBtn: {
              loading: true,
            },
          })
          this.$api.cgzh.review.setTeamLeader({
            teamId: row.teamId,
            expertsId: row.experts.id,
          }).then(res => {
            this.$message.success('设置成功')
            this.teamExpertGet()
            confirmDia.destroy();
          }).catch((e) => {
            confirmDia.update({
              confirmBtn: {
                loading: false,
              },
            })
            this.$message.error(e.toString());
          });
        },
      })
    },
    // 删除专家
    teamExpertDel(id) {
      const confirmDia = this.$dialog.confirm({
        header: "系统提示",
        body: `是否确认删除？`,
        theme: "warning",
        onConfirm: ({e}) => {
          confirmDia.update({
            confirmBtn: {
              loading: true,
            },
          })
          this.$api.cgzh.review.teamExpertDel(id).then(res => {
            this.$message.success('删除成功')
            this.teamExpertGet()
            confirmDia.destroy();
          }).catch((e) => {
            confirmDia.update({
              confirmBtn: {
                loading: false,
              },
            })
            this.$message.error(e.toString());
          });
        },
      })
    },
  }
}
</script>

<style scoped lang="less">
@import url("@/style/duty.less");
</style>
